package awt;

import javax.swing.*;
import java.awt.*;

public class Comment {
        JFrame f=new JFrame("无敌牛牛");
        Button ok=new Button("sure");
//        Button name=new Button("临时");
        CheckboxGroup cbg=new CheckboxGroup();
        //定义单选框，被选中
        Checkbox male=new Checkbox("male",cbg,true);
        Checkbox female=new Checkbox("female",cbg,false);
        Checkbox married=new Checkbox("is married",false);
        //下拉选择框
        Choice colorChooser=new Choice();
        //列表选择框
        List colorList=new List(6,true);
        //5行20列文本域
        TextArea ta=new TextArea(8,20);
        public void init()
        {
            colorChooser.add("red");
            colorChooser.add("green");
            colorChooser.add("blue");
            colorList.add("red");
            colorList.add("green");
            colorList.add("blue");
            //创建装在文本框和按钮的Panel底部面板
            Panel bottom=new Panel();
//            bottom.add(name);
            bottom.add(ok);
            f.add(bottom,BorderLayout.SOUTH);
            //创建装在下拉选择框，三个checkbox的panel
            Panel checkPanel =new Panel();
            checkPanel.add(colorChooser);
            checkPanel.add(male);
            checkPanel.add(female);
            checkPanel.add(married);
            //创建垂直排列组件的box承装多行文本域，panel
            Box topLeft=Box.createVerticalBox();
            topLeft.add(ta);
            topLeft.add(colorList);
            //将单选面板添加到布局中
            topLeft.add(checkPanel);
            //水平排列组件box承装topleft,colorlist
            Box top = Box.createHorizontalBox();
            top.add(topLeft);
            top.add(colorList);
            //top box容器添加到窗口中间
            f.add(top);
            f.setSize(600,500);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setVisible(true);
        }

    public static void main(String[] args) {
            new Comment().init();
    }


}
